package com.example.jetpack

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.jetpack.a_viewbinding.ViewBindingActivity
import com.example.jetpack.b_viewModel_livedata.BActivity
import com.example.jetpack.c_lifecycle.CActivity
import com.example.jetpack.databinding.ActivityMainBinding
import com.example.jetpack.room.RoomActivity
import com.example.material.util.launchActivity

class MainActivity : AppCompatActivity() {
    private lateinit var binding: ActivityMainBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        binding = ActivityMainBinding.inflate(layoutInflater)
        val view = binding.root
        setContentView(view)
        ViewCompat.setOnApplyWindowInsetsListener(view) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        initButtons()


        launchActivity<RoomActivity>()
    }

    private fun initButtons() {
        binding.viewBindingBtn.setOnClickListener {
            launchActivity<ViewBindingActivity>()
        }
        binding.viewModelBtn.setOnClickListener {
            launchActivity<BActivity>()
        }
        binding.lifecycleBtn.setOnClickListener {
            launchActivity<CActivity>()
        }
        binding.roomBtn.setOnClickListener {
            launchActivity<RoomActivity>()
        }
    }
}